package com.kaifamiao.repositories;

import com.kaifamiao.entity.User;
import org.springframework.data.jdbc.repository.query.Modifying;
import org.springframework.data.jdbc.repository.query.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

@Repository
public interface UserRepository extends CrudRepository<User, Integer>, BaseRepository<User> {

    User findByEmail(String email);

    User getByEmail(String email);

    long countByEmail(String email);

    @Modifying
    @Query("DELETE FROM t_users WHERE id = :id")
    void removeById( @Param("id") Integer id);

}
